<!-- 修改账单金额 -->
<template>
  <el-dialog title="修改账单金额" v-model="dialog" width="30%" @closed="closedFormDialog">
    <el-form :model="form" label-width="150px" v-loading="loading">
      <el-row :gutter="10">
        <el-col :span="20">
          <el-form-item label="账单金额：" prop="price">
            <el-input v-model="form.price" placeholder="修改登录手机号"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button :disabled="disabledbtn" @click="closedFormDialog">取 消</el-button>
        <el-button type="primary" :disabled="disabledbtn" @click="handlePutChangePriceInfo">确 定</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { useState } from "@/hooks/useState.ts";
import { putTnstallmentBillPriceInfo } from "@/utils/api/installmentBill";
import type { IChangePriceInfo } from "@/types/rentMachineManage/installmentBill";
const { disabledbtn, loading, toggleState } = useState();
const dialog = defineModel<boolean>("dialog", { required: true });
const form = defineModel<IChangePriceInfo>("form", { required: true });
const emit = defineEmits<{
  handleSuccess: [];
}>();
/* 修改账单金额 */
function handlePutChangePriceInfo() {
  if (form.value.price === "") {
    ElMessage.warning("请填写修改的账单金额");
    return;
  }
  toggleState(true);
  putTnstallmentBillPriceInfo(form.value)
    .then(() => {
      ElMessage.success("修改成功");
      emit("handleSuccess");
      closedFormDialog();
    })
    .catch(() => {})
    .finally(() => {
      toggleState(false);
    });
}

// 关闭模态框
function closedFormDialog() {
  dialog.value = false;
  form.value.price = "";
  form.value.id = 0;
}
</script>

<style lang="scss" scoped>
/* Add your styles here */
</style>
